<?php

namespace app\api\validate;


use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username' => 'require',
        'phone_number' => 'require|length:11|/^1[34578]\d{9}$/|number',
        'code' => 'require|number|min:4',
        'type' => 'require|in:1,2',
        'sex' => 'require|in:0,1,2'

    ];

    protected $message = [
        'username' => '用户名必须',
        'phone_number.require' => '电话号码必须',
        'phone_number.length' => '手机号码必须为11位，请检查。',
        'phone_number' => '您输入的手机号码有问题，请检查。',
        'code.require' => '验证码必须',
        'code.number' => '验证码必须是数字',
        'type.require' => '类型必须',
        'type.in' => '类型值错误',
        'sex.require' => '性别必须',
        'sex.in' => '性别数值错误',

    ];

    protected $scene = [
        'send_code' => ['phone_number'],
        'login' => ['phone_number', 'code', 'type'],
        'update_user' => ['username', 'sex'],
    ];
}